//
//
//
//
// Socks4Proxy.h
//

#ifndef SOCKS4_PROXY_H_
#define SOCKS4_PROXY_H_

#include "common.h"
#include "BaseJob.h"
#include "NixTimer.h"

class Socks4Proxy : public BaseJob, public NixTimer
{
	public:
		Socks4Proxy(jobId_t id, 
				const std::string& jobName,
				void* arg,
				int clientFD);

		virtual ~Socks4Proxy();
		
		bool Audit();
		virtual void Run();
		virtual void TimerSvc(void);
		virtual void PrintAll(std::ostream& os);

	private:
		// Recv data from client and parse
		bool GetCmd(void);
		// try to connect remote server use the current profile
		// if failed, it return false and release sytem resource.
		bool CrtSockPeer(void);

	private:
		int _clientFD;
		int _serverFD;

		//
		// cmd information
		U8	_version;
		U8	_cmd;

		// network order
		U16 _port;

		// network order
		U32 _ip;
		char _szUid[64];
};

#endif // SOCKS4_PROXY_H_
